{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<form action="" method="post" class="form form-horizontal" id="form-admin-role-add">
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">
					<span class="c-red">*</span>角色名称：</label>
				<div class="formControls col-xs-6 col-sm-2">
					<input type="text" class="input-text" value="" placeholder="" id="role_name" name="role_name" datatype="*4-16" nullmsg="用户账户不能为空">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">管理权限选择：</label>
				<div class="formControls col-xs-6 col-sm-7">
					<dl class="permission-list">
						<dd>
						{foreach $data_permission as $value}
							<dl class="cl permission-list2">
								<dt>
									<label>
										<input type="checkbox" class="parent" value="{$value.id}" name="check[]" id="check_{$value.id}">
										{$value.name}
									</label>
									<dd>
										{notempty name='value.child'}
										{foreach $value.child as $val}
										<label>
											<input type="checkbox" class="child pid_{$val.pid}" data-pid="{$val.pid}" value="{$val.id}" name="check[]" id="check_{$val.id}">
											{$val.name}
										</label>
										{/foreach}
										{/notempty}
									</dd>
								</dt>
							</dl>
						{/foreach}
						</dd>
					</dl>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-2 col-sm-2">备注：</label>
				<div class="formControls col-xs-8 col-sm-4">
					<textarea id="description" name="description" cols="" rows="" class="textarea" placeholder="备注...200个字符以内" dragonfly="true"
					    onKeyUp="textarealength(this,200)"></textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/200</p>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button type="submit" class="btn btn-success radius" id="admin-role-save" name="">
						<i class="icon-ok"></i> 确定</button>
					<input class="btn btn-default radius" type="button" value="取消" onClick="window.history.back();">
				</div>
			</div>
		</form>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
	$(".child").click(function(){
		var pid = $(this).data('pid');

		$("#check_"+pid).prop('checked', true);
	})

	$(".parent").click(function(){
		var id = $(this).val();
		var status = $(this).prop('checked');

		if (status) {
			$(".pid_"+id).prop('checked', !$(".pid_"+id).prop('checked'));
		} else {
			$(".pid_"+id).prop('checked', false);
		}		
	})
})
</script>
<!--请在上方写此页面业务相关的脚本-->